# Automake file

# Flags for aclocal:
ACLOCAL_AMFLAGS = -I m4

# shared libraries to build
lib_LTLIBRARIES = lib/libparser.la

# libparser

lib_libparser_la_SOURCES = \
	src/block_node.cpp \
	src/block_entry_node.cpp \
	src/if_statement_node.cpp \
	src/statement_node.cpp \
	src/mutation_node.cpp \
	src/procedure_call_node.cpp \
	src/function_call_node.cpp \
	src/operation_node.cpp \
	src/expression_node.cpp \
	src/name_node.cpp \
	src/compound_name_node.cpp \
	src/indexed_name_node.cpp \
	src/scoped_name_node.cpp \
	src/dereferenced_name_node.cpp \
	src/internal_name_node.cpp \
	src/immediate_node.cpp \
	src/immediate_number_node.cpp \
	src/symbol_node.cpp \
	src/label_node.cpp \
	src/ws_parser.cpp \
	src/parse_tree_node.cpp

pkginclude_HEADERS = \
	include/block_node.hpp \
	include/block_entry_node.hpp \
	include/if_statement_node.hpp \
	include/statement_node.hpp \
	include/mutation_node.hpp \
	include/procedure_call_node.hpp \
	include/function_call_node.hpp \
	include/operation_node.hpp \
	include/expression_node.hpp \
	include/name_node.hpp \
	include/compound_name_node.hpp \
	include/indexed_name_node.hpp \
	include/scoped_name_node.hpp \
	include/dereferenced_name_node.hpp \
	include/internal_name_node.hpp \
	include/immediate_node.hpp \
	include/immediate_number_node.hpp \
	include/symbol_node.hpp \
	include/label_node.hpp \
	include/ws_parser.hpp \
	include/parse_tree_node.hpp

lib_libparser_la_CPPFLAGS	= $(AM_CPPFLAGS) \
														$(BOOST_CPPFLAGS) \
														-I$(srcdir)/include
lib_libparser_la_CXXFLAGS	= $(AM_CXXFLAGS)
lib_libparser_la_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS)
lib_libparser_la_LIBADD	= $(BOOST_REGEX_LIB) \
													$(MPFR_LIBS) \
													$(GMPXX_LIBS) \
													$(GMP_LIBS)

#
# Testing
#

# Setup the variables we use below.
check_PROGRAMS =
TEST_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_CPPFLAGS) $(GTEST_CPPFLAGS) \
								-I$(srcdir)/include
TEST_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS) $(GTEST_LDFLAGS)
TEST_LDADD = lib/libparser.la $(GTEST_LIBS)

check_PROGRAMS += test/ws_parser_test
test_ws_parser_test_SOURCES = test/ws_parser_test.cpp
test_ws_parser_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_ws_parser_test_LDFLAGS = $(TEST_LDFLAGS)
test_ws_parser_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/label_node_test
test_label_node_test_SOURCES = test/label_node_test.cpp
test_label_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_label_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_label_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/symbol_node_test
test_symbol_node_test_SOURCES = test/symbol_node_test.cpp
test_symbol_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_symbol_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_symbol_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/immediate_number_node_test
test_immediate_number_node_test_SOURCES = test/immediate_number_node_test.cpp
test_immediate_number_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_immediate_number_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_immediate_number_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/immediate_node_test
test_immediate_node_test_SOURCES = test/immediate_node_test.cpp
test_immediate_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_immediate_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_immediate_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/internal_name_node_test
test_internal_name_node_test_SOURCES = test/internal_name_node_test.cpp
test_internal_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_internal_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_internal_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/dereferenced_name_node_test
test_dereferenced_name_node_test_SOURCES = test/dereferenced_name_node_test.cpp
test_dereferenced_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_dereferenced_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_dereferenced_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/scoped_name_node_test
test_scoped_name_node_test_SOURCES = test/scoped_name_node_test.cpp
test_scoped_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_scoped_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_scoped_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/indexed_name_node_test
test_indexed_name_node_test_SOURCES = test/indexed_name_node_test.cpp
test_indexed_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_indexed_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_indexed_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/compound_name_node_test
test_compound_name_node_test_SOURCES = test/compound_name_node_test.cpp
test_compound_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_compound_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_compound_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/name_node_test
test_name_node_test_SOURCES = test/name_node_test.cpp
test_name_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_name_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_name_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/expression_node_test
test_expression_node_test_SOURCES = test/expression_node_test.cpp
test_expression_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_expression_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_expression_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/operation_node_test
test_operation_node_test_SOURCES = test/operation_node_test.cpp
test_operation_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_operation_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_operation_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/function_call_node_test
test_function_call_node_test_SOURCES = test/function_call_node_test.cpp
test_function_call_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_function_call_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_function_call_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/procedure_call_node_test
test_procedure_call_node_test_SOURCES = test/procedure_call_node_test.cpp
test_procedure_call_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_procedure_call_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_procedure_call_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/mutation_node_test
test_mutation_node_test_SOURCES = test/mutation_node_test.cpp
test_mutation_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_mutation_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_mutation_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/statement_node_test
test_statement_node_test_SOURCES = test/statement_node_test.cpp
test_statement_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_statement_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_statement_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/if_statement_node_test
test_if_statement_node_test_SOURCES = test/if_statement_node_test.cpp
test_if_statement_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_if_statement_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_if_statement_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/block_entry_node_test
test_block_entry_node_test_SOURCES = test/block_entry_node_test.cpp
test_block_entry_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_block_entry_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_block_entry_node_test_LDADD = $(TEST_LDADD)

check_PROGRAMS += test/block_node_test
test_block_node_test_SOURCES = test/block_node_test.cpp
test_block_node_test_CPPFLAGS = $(TEST_CPPFLAGS)
test_block_node_test_LDFLAGS = $(TEST_LDFLAGS)
test_block_node_test_LDADD = $(TEST_LDADD)

TESTS	= $(check_PROGRAMS)

#
#	Coverage Analysis
#

if ENABLE_COVERAGE

EXTRA_LTLIBRARIES						= test/libparser_coverage.la

test_libparser_coverage_la_SOURCES = $(lib_libparser_la_SOURCES)
test_libparser_coverage_la_CPPFLAGS = $(lib_libparser_la_CPPFLAGS)
test_libparser_coverage_la_CXXFLAGS = $(lib_libparser_la_CXXFLAGS) --coverage
test_libparser_coverage_la_LDFLAGS = $(lib_libparser_la_LDFLAGS) --coverage
test_libparser_coverage_la_LIBADD = $(lib_libparser_la_LIBADD)

# Setup the variables we use below.
EXTRA_PROGRAMS =
COVERAGE_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_CPPFLAGS) $(GTEST_CPPFLAGS) \
										-I$(srcdir)/include
COVERAGE_CXXFLAGS = $(AM_CXXFLAGS) --coverage
COVERAGE_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS) $(GTEST_LDFLAGS) --coverage
COVERAGE_LDADD = lib/libparser_coverage.la $(GCOVERAGE_LIBS)

EXTRA_PROGRAMS += test/ws_parser_coverage
test_ws_parser_coverage_SOURCES = test/ws_parser_test.cpp
test_ws_parser_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_ws_parser_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_ws_parser_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_ws_parser_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/label_node_coverage
test_label_node_coverage_SOURCES = test/label_node_test.cpp
test_label_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_label_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_label_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_label_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/symbol_node_coverage
test_symbol_node_coverage_SOURCES = test/symbol_node_test.cpp
test_symbol_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_symbol_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_symbol_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_symbol_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/immediate_number_node_coverage
test_immediate_number_node_coverage_SOURCES = test/immediate_number_node_test.cpp
test_immediate_number_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_immediate_number_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_immediate_number_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_immediate_number_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/immediate_node_coverage
test_immediate_node_coverage_SOURCES = test/immediate_node_test.cpp
test_immediate_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_immediate_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_immediate_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_immediate_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/internal_name_node_coverage
test_internal_name_node_coverage_SOURCES = test/internal_name_node_test.cpp
test_internal_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_internal_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_internal_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_internal_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/dereferenced_name_node_coverage
test_dereferenced_name_node_coverage_SOURCES = test/dereferenced_name_node_test.cpp
test_dereferenced_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_dereferenced_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_dereferenced_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_dereferenced_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/scoped_name_node_coverage
test_scoped_name_node_coverage_SOURCES = test/scoped_name_node_test.cpp
test_scoped_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_scoped_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_scoped_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_scoped_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/indexed_name_node_coverage
test_indexed_name_node_coverage_SOURCES = test/indexed_name_node_test.cpp
test_indexed_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_indexed_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_indexed_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_indexed_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/compound_name_node_coverage
test_compound_name_node_coverage_SOURCES = test/compound_name_node_test.cpp
test_compound_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_compound_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_compound_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_compound_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/name_node_coverage
test_name_node_coverage_SOURCES = test/name_node_test.cpp
test_name_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_name_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_name_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_name_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/expression_node_coverage
test_expression_node_coverage_SOURCES = test/expression_node_test.cpp
test_expression_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_expression_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_expression_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_expression_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/operation_node_coverage
test_operation_node_coverage_SOURCES = test/operation_node_test.cpp
test_operation_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_operation_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_operation_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_operation_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/function_call_node_coverage
test_function_call_node_coverage_SOURCES = test/function_call_node_test.cpp
test_function_call_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_function_call_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_function_call_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_function_call_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/procedure_call_node_coverage
test_procedure_call_node_coverage_SOURCES = test/procedure_call_node_test.cpp
test_procedure_call_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_procedure_call_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_procedure_call_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_procedure_call_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/mutation_node_coverage
test_mutation_node_coverage_SOURCES = test/mutation_node_test.cpp
test_mutation_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_mutation_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_mutation_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_mutation_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/statement_node_coverage
test_statement_node_coverage_SOURCES = test/statement_node_test.cpp
test_statement_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_statement_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_statement_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_statement_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/if_statement_node_coverage
test_if_statement_node_coverage_SOURCES = test/if_statement_node_test.cpp
test_if_statement_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_if_statement_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_if_statement_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_if_statement_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/block_entry_node_coverage
test_block_entry_node_coverage_SOURCES = test/block_entry_node_test.cpp
test_block_entry_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_block_entry_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_block_entry_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_block_entry_node_coverage_LDADD = $(COVERAGE_LDADD)

EXTRA_PROGRAMS += test/block_node_coverage
test_block_node_coverage_SOURCES = test/block_node_test.cpp
test_block_node_coverage_CPPFLAGS = $(COVERAGE_CPPFLAGS)
test_block_node_coverage_CXXFLAGS = $(COVERAGE_CXXFLAGS)
test_block_node_coverage_LDFLAGS = $(COVERAGE_LDFLAGS)
test_block_node_coverage_LDADD = $(COVERAGE_LDADD)

coverage-clean:
	rm -f $(builddir)/*.gcda
	rm -f $(builddir)/.libs/*.gcda
	rm -f $(builddir)/_libs/*.gcda
	rm -f $(builddir)/lib/*.gcda
	rm -f $(builddir)/lib/.libs/*.gcda
	rm -f $(builddir)/lib/_libs/*.gcda
	rm -f $(builddir)/test/*.gcda
	rm -f $(builddir)/test/.libs/*.gcda
	rm -f $(builddir)/test/_libs/*.gcda

test/coverage_baseline.info: coverage-clean $(EXTRA_PROGRAMS)
	$(LCOV) -c -i -d . -o $(builddir)/test/coverage_baseline.info

coverage-runtests: test/coverage_baseline.info coverage-clean $(EXTRA_PROGRAMS)
	:

test/coverage_testrun.info: coverage-runtests
	$(LCOV) -c -d . -o $(builddir)/test/coverage_testrun.info

test/coverage_total.info: test/coverage_baseline.info test/coverage_testrun.info
	$(LCOV) -a $(builddir)/test/coverage_baseline.info -a $(builddir)/test/coverage_testrun.info -o $(builddir)/test/coverage_total.info

test/coverage_final.info: test/coverage_total.info
	$(LCOV) -o $(builddir)/test/coverage_final.info -e $(builddir)/test/coverage_total.info "$(abspath $(srcdir))/*"

coverage: test/coverage_final.info
	$(GENHTML) --legend --show-details -o $(builddir)/test/coverage $(builddir)/test/coverage_final.info

endif

#
# Documentation
#

if ENABLE_DOXYGEN

doc: doxygen.cfg $(pkginclude_HEADERS) $(libparser_la_SOURCES)
	rm -rf $(builddir)/doc
	$(DOXYGEN) $(builddir)/doxygen.cfg

EXTRA_DIST = doxygen.cfg

endif

#
#	Miscellaneous cleanup
#

mostlyclean-local: coverage-clean
	rm -rf $(builddir)/doc
	rm -rf $(builddir)/test/coverage
	rm -f $(builddir)/*.gcno
	rm -f $(builddir)/*/*.gcno
	rm -f $(builddir)/*/*/*.gcno

# vim: noet ts=2 sts=2 sw=2

